package pers.vic.test.some.pandc;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * 消费者
 * @author VIC
 *
 */
public class Consumer implements Runnable{

	private BlockingQueue<Integer> queue;
	
	
	
	
	public Consumer(BlockingQueue<Integer> queue) {
		super();
		this.queue = queue;
	}




	@Override
	public void run() {
		try {
			while(true) {
				TimeUnit.SECONDS.sleep(4);
				consume(queue.take());
			}
		}catch (Exception e) {
		}
	}




	private void consume(Integer take) {
		String s = Thread.currentThread().getName()  + "--> 消费:" + take;
		System.out.println(s);
		
	}

}
